package com.sirdc.modules.sys.dao;

import com.sirdc.modules.core.dao.GenericQuery;
import com.sirdc.modules.core.dao.StringDao;
import com.sirdc.modules.sys.entity.SysDept;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: ling
 * Date: 2019/7/9
 * Time: 17:46
 * To change this template use File | Settings | File Templates.
 * Description:
 */

@Repository
public class DeptDao extends StringDao<SysDept> {

    public List<SysDept> queryDeptList(String deptRelation){
        GenericQuery query = createQuery("obj");
        query.append(" and obj.deptRelation =:deptRelation").setParam("deptRelation", deptRelation);
        return query.listResult();
    }

    public List<SysDept> getByName(String deptName) {
        GenericQuery query = createQuery("obj");
        query.append(" and obj.deptName =:deptName").setParam("deptName", deptName);
        return query.listResult();
    }

    public List<SysDept> queryByDeptLevel(int deptLevel) {
        GenericQuery query = createQuery("obj");
        query.append(" and obj.deptLevel =:deptLevel").setParam("deptLevel", deptLevel);
        query.append(" and obj.deptRelation like:deptRelation").setParam("deptRelation", "%/02/%");
        return query.listResult();
    }
}
